<!doctype html>
<html>
  <head>
    <title>Notifications: Verifying the exception throwing behavior, when silent set true and vibrate is presented in showNotification().</title>
    <script src="../resources/testharness.js"></script>
    <script src="../resources/testharnessreport.js"></script>
    <script src="../serviceworker/resources/test-helpers.js"></script>
  </head>
  <body>
    <script>
      // Tests that the showNotification() function rejects the returned promise with a
      // TypeError when silent set true and vibrate is presented.
      async_test(function(test) {
          var scope = 'resources/scope/' + location.pathname,
              workerUrl = 'resources/empty-worker.js';

          testRunner.setPermission('notifications', 'granted', location.origin, location.origin);

          var registration = null;
          service_worker_unregister_and_register(test, workerUrl, scope).then(function(swRegistration) {
              registration = swRegistration;
              return wait_for_state(test, registration.installing, 'activated');
          }).then(function() {
              registration.showNotification('Title', {
                  body: 'Hello, world!',
                  vibrate: [100, 200, 300],
                  silent: true
              }).then(function() {
                  assert_unreached('showNotification() is expected to reject.');
              }).catch(function(error) {
                  assert_equals(error.name, 'TypeError');
                  assert_equals(error.message, "Failed to execute 'showNotification' on 'ServiceWorkerRegistration': Silent notifications must not specify vibration patterns.");
                  test.done();
              });

          }).catch(unreached_rejection(test));

      }, 'showNotification() must reject If options\'s silent is true, and options\'s vibrate is presenteded.');
    </script>
  </body>
</html>
